﻿using SingleBlog.Core.Resources;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace SingleBlog.Core.Data
{
    /// <summary>
    /// 首页导航。
    /// </summary>
    [Table("Navigations")]
    public class Navigation
    {
        [Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }
        /// <summary>
        /// 导航名称。
        /// </summary>
        [Display(Name="导航名称")]
        [StringLength(50,ErrorMessageResourceName ="StringLength",ErrorMessageResourceType =typeof(Language))]
        [Required(ErrorMessageResourceName ="Required",ErrorMessageResourceType =typeof(Language))]
        public string Name { get; set; }
        /// <summary>
        /// 导航url
        /// </summary>
        [Display(Name = "导航链接")]
        [StringLength(300, ErrorMessageResourceName = "StringLength", ErrorMessageResourceType = typeof(Language))]
        [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(Language))]
        public string Url { get; set; }
        /// <summary>
        /// 是否启用
        /// </summary>
        [Display(Name = "是否启用")]
        public bool Enabled { get; set; } = true;
        /// <summary>
        /// 排序
        /// </summary>
        [Display(Name = "排序")]
        public int OrderNo { get; set; }
        /// <summary>
        /// 父导航Id。
        /// </summary>
        public int? ParentId { get; set; }

        /// <summary>
        /// 父导航。
        /// </summary>
        public virtual Navigation ParentNavigation { get; set; }

        /// <summary>
        /// 子导航。
        /// </summary>
        public virtual ICollection<Navigation> ChildNavigation { get; set; }= new HashSet<Navigation>();
    }
}
